from page_objects.Shangjia_page import ShangjiaPage
from selenium.webdriver.common.by import By

class XiajiaPage(ShangjiaPage):
    # 添加用户支付配置模块
    # 元素定位器
    # 1.定位下架
    xj_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[2]/div[2]/div[2]/div[2]/div/table/tbody/tr[1]/td[6]/div/a[2]')
    # 2.定位确认
    qd_xj_loc = (By.XPATH, '/html/body/div[13]/div[1]/div/div[2]/ul/li[1]/a/span')
    # 3.定位用户支付配置
    pay_pz_loc=(By.XPATH,'/html/body/div[1]/div[2]/div[2]/div[2]/div[8]/ul/li[2]/div/a')
    # 4.定位添加支付配置
    add_pz_loc = (By.CLASS_NAME, 'add')
    # 5.定位用户编号输入框
    userNo_loc = (By.NAME, 'user.userNo')
    # 6.定位用户名输入框
    product_xia_name_loc = (By.NAME, 'user.userName')
    # 7.定位支付产品编号输入框
    pay_product_no_loc = (By.NAME, 'product.productCode')
    # 支付产品名称输入框
    pay_product_name_loc = (By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[3]/div/form/div[1]/div/fieldset[1]/dl[4]/dd/input')
    # Ip白名单输入框
    pay_product_IPbmd_loc = (By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[3]/div/form/div[1]/div/fieldset[1]/dl[9]/dd/textarea')
    # 7.定位风险预存期输入框
    riskDay_loc = (By.NAME, 'riskDay')
    # 8.定位收款方式select
    sk_fs_loc = (By.ID, 'fundIntoType')
    # 9.定位支付产品输入框
    productCode_loc = (By.NAME, 'product.productCode')
    # 10.定位安全等级select
    aq_dj_loc = (By.ID, 'securityRating')
    # 断言3--用户支付配置
    dy33_loc=(By.XPATH,'/html/body/div[1]/div[3]/div/div[2]/div[3]/div/form/div[1]/div/fieldset[1]/legend')
    # 断言4--确定要下架吗?
    dy44_loc=(By.XPATH,'/html/body/div[13]/div[1]/div/div[1]/div')
    # 11.定位提交
    pz_commit_loc = (By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[3]/div/form/div[2]/ul/li[1]/div/div/button')
    # 12.点击下架
    # product_xj_loc = (By.XPATH, '/html/body/div[1]/div[3]/div/div[2]/div[4]/div[2]/div[2]/div[2]/div/table/tbody/tr[1]/td[6]/div/a[2]')
    # 元素的操作方法
    # 1.点击下架
    def click_xj(self):
        self.click(self.xj_loc)
        return self
    # 2.点击确定
    def click_xj_qd(self):
        self.click(self.qd_loc)
        return self
    # 3.点击用户支付配置
    def click_pay_pz(self):
        self.click(self.pay_pz_loc)
        return self
    # 4.点击添加支付配置
    def click_add_pay_pz(self):
        self.click(self.add_pz_loc)
        return self
    # 5.输入用户编号编码
    def input_pz_user_no(self, user_no):
        self.send_keys(self.userNo_loc, user_no)
        return self
    # 6.输入用户名
    def input_pz_user_name(self, user_name):
        self.send_keys(self.product_xia_name_loc, user_name)
        return self
    # 7.输入支付产品编号
    def input_pz_product_no(self, user_name):
        self.send_keys(self.pay_product_no_loc, user_name)
        return self
    # 输入支付产品名称
    def input_pz_product_name(self, user_name):
        self.send_keys(self.pay_product_name_loc, user_name)
        return self
    # 输入商品IP白名单
    def input_pz_product_bmd(self, user_name):
        self.send_keys(self.pay_product_IPbmd_loc, user_name)
        return self
    # 8.select收款方式
    def select_sk_fs(self):
        self.select_value(self.sk_fs_loc,'PLAT_RECEIVES')
        return self
    # 9.输入风险预存期
    def input_risk_day(self, risk_day):
        self.send_keys(self.riskDay_loc, risk_day)
        return self
    # 10.select安全等级
    def select_aq_dj(self):
        self.select_value(self.aq_dj_loc,'MD5_IP')
        return self
    # 11.支付配置，点击提交
    def click_pz_commit(self):
        self.click(self.pz_commit_loc)
        return self
    # 12.点击下架
    # def click_product_xj(self):
    #     self.click(self.product_xj_loc)
    #     return self



